package com.example.demo.common;

import lombok.Data;

/**
 * Created with IntelliJ IDEA.
 * Description:  Ctrl + Alt + L自动格式化代码
 * User: yyx
 * Date: 2023-11-05
 * Time: 16:12
 */
@Data
public class ResultAjax {
    private int code;//状态码
    private String msg;//状态信息
    private Object data;//数据

    //设置成功失败方法
    public static ResultAjax succ(Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(200);
        result.setMsg("");
        result.setData(data);
        return result;
    }
    public static ResultAjax succ(String msg,Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(200);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }


    public static ResultAjax fail(int code,String msg){
        ResultAjax result = new ResultAjax();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(null);
        return result;
    }
    public static ResultAjax fail(int code,String msg,Object data){
        ResultAjax result = new ResultAjax();
        result.setCode(code);
        result.setMsg(msg);
        result.setData(data);
        return result;
    }

}
